package com.project.zsxd.server.task;

import com.project.zsxd.server.common.util.LogUtil;
import com.project.zsxd.server.sleepInfo.service.ISleepInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 睡眠信息刷新任务
 */
@Component
public class SleepInfoTask {

    @Autowired
    private ISleepInfoService sleepInfoService;

    @Scheduled(cron = "${task.cron.sleepInfo:0 0 12 * * ?}")
    public void execute() {
        LogUtil.info("start SleepInfoTask");
        try {
            sleepInfoService.batchRefreshSleepInfo();
        } catch (Exception e) {
            LogUtil.error("batchRefreshSleepInfo error." + e.getLocalizedMessage(), e);
        }
        LogUtil.info("finish SleepInfoTask");
    }


}
